// const webpack = require('webpack')
const path = require('path')

module.exports = {
  // publicPath: '/admin/',
  // axios域代理，解决axios跨域问题
  devServer: {
    port: 8080,
    proxy: {
      "/api": {
        target: "http://59.110.23.5:11771/",
        changeOrigin: true,
        pathRewrite: {
            "^/api": ""
        }
      }
    }
  },
  pluginOptions: {
    lintStyleOnBuild: true,
    stylelint: {
      fix: true
    }
  },
  configureWebpack: config => {
    // 生产去除console.log
    if (process.env.NODE_ENV === "production") {
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
    }
  },
  chainWebpack: config => {
    //
    config.module
      .rule('svg')
      .exclude.add(path.join(__dirname, 'src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(path.join(__dirname, 'src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
          symbolId: 'icon-[name]'
      })
      .end()
    // 标题
    config.plugin("html")
      .tap(args => {
          args[0].title = "XXXX平台后台管理";
          return args;
      })
      .end()
  }
};
